package com.yanqu.road.entity.player;

import com.alibaba.fastjson.JSON;
import com.yanqu.road.entity.DataObject;

import java.util.LinkedList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 玩家游历数据
 */
public class UserTravel extends DataObject {

	private long userId;
	/**
	 * 城市下标
	 */
	private int cityId;

	private int travelTimes;

	private long modifyTime;

	private long totalTravelTimes;

	private long totalBeautyEncounterTimes;         //累计美女偶遇次数

	private int power;                //体力

	private long lastRestoreTime;     //上次体力恢复时间

	private long totalCasinoTimes;    //累计赌博次数

	private LinkedList<Integer> multiChildTypeList = new LinkedList<>();      //多胞胎类型列表

	private LinkedList<Integer> eventIdList = new LinkedList<>();             //特殊事件列表

	private LinkedList<Integer> beautyTrystList = new LinkedList<>();         //美女指定传唤列表

	private int brothelBeautyId;                                              //青楼美女编号，缓存不入库

	private int casinoType;                                                   //骰子事件类型值，缓存不入库

	private Map<Integer, Long> travelEventTimesMap = new ConcurrentHashMap<>(); //游历事件
	private Map<Integer, Long> todayEventTimesMap = new ConcurrentHashMap<>(); //游历事件

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		if (this.userId != userId) {
			this.userId = userId;
			setUpdateOption();
		}
	}

	public int getCityId() {
		return cityId;
	}

	public void setCityId(int cityId) {
		if(this.cityId != cityId) {
			this.cityId = cityId;
			setUpdateOption();
		}
	}

	public int getTravelTimes() {
		return travelTimes;
	}

	public void setTravelTimes(int travelTimes) {
		if(this.travelTimes != travelTimes) {
			this.travelTimes = travelTimes;
			setUpdateOption();
		}
	}

	public long getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(long modifyTime) {
		if(this.modifyTime != modifyTime) {
			this.modifyTime = modifyTime;
			setUpdateOption();
		}
	}

	public long getTotalTravelTimes() {
		return totalTravelTimes;
	}

	public void setTotalTravelTimes(long totalTravelTimes) {
		if(this.totalTravelTimes != totalTravelTimes) {
			this.totalTravelTimes = totalTravelTimes;
			setUpdateOption();
		}
	}

	public long getTotalBeautyEncounterTimes() {
		return totalBeautyEncounterTimes;
	}

	public void setTotalBeautyEncounterTimes(long totalBeautyEncounterTimes) {
		if(this.totalBeautyEncounterTimes != totalBeautyEncounterTimes) {
			this.totalBeautyEncounterTimes = totalBeautyEncounterTimes;
			setUpdateOption();
		}
	}

	public String getTravelEventTimesMapJsonString() {
		return JSON.toJSONString(travelEventTimesMap);
	}

	public void setTravelEventTimesMap(Map<Integer, Long> travelEventTimesMap) {
		this.travelEventTimesMap = travelEventTimesMap;
		setUpdateOption();
	}

	public long getTravelEventTimes(int eventId){
		if(travelEventTimesMap.containsKey(eventId)){
			return travelEventTimesMap.get(eventId);
		}
		return 0;
	}

	public void addTravelEventTimes(int eventId){
		long times = getTravelEventTimes(eventId);
		times++;
		travelEventTimesMap.put(eventId, times);
		setUpdateOption();
	}

	public String getTodayEventTimesMapJsonString() {
		return JSON.toJSONString(todayEventTimesMap);
	}

	public long getTodayEventTimes(int eventId){
		if(todayEventTimesMap.containsKey(eventId)){
			return todayEventTimesMap.get(eventId);
		}
		return 0;
	}

	public void addTodayEventTimes(int eventId){
		long times = getTodayEventTimes(eventId);
		times++;
		todayEventTimesMap.put(eventId, times);
		setUpdateOption();
	}

	public void clearTodayEventTimes() {
		todayEventTimesMap.clear();
		setUpdateOption();
	}

	public void setTodayEventTimesMap(Map<Integer, Long> todayEventTimesMap) {
		this.todayEventTimesMap = todayEventTimesMap;
		setUpdateOption();
	}

	public int getPower() {
		return power;
	}

	public void setPower(int power) {
		if(this.power != power) {
			this.power = power;
			setUpdateOption();
		}
	}

	public long getLastRestoreTime() {
		return lastRestoreTime;
	}

	public void setLastRestoreTime(long lastRestoreTime) {
		if(this.lastRestoreTime != lastRestoreTime) {
			this.lastRestoreTime = lastRestoreTime;
			setUpdateOption();
		}
	}

	public long getTotalCasinoTimes() {
		return totalCasinoTimes;
	}

	public void setTotalCasinoTimes(long totalCasinoTimes) {
		if(this.totalCasinoTimes != totalCasinoTimes) {
			this.totalCasinoTimes = totalCasinoTimes;
			setUpdateOption();
		}
	}

	public LinkedList<Integer> getMultiChildTypeList() {
		return multiChildTypeList;
	}

	public void setMultiChildTypeList(LinkedList<Integer> multiChildTypeList) {
		this.multiChildTypeList = multiChildTypeList;
		setUpdateOption();
	}

	public void addMultiChildType(int multiChildType){
		multiChildTypeList.addLast(multiChildType);
		setUpdateOption();
	}

	public int removeMultiChildType(){
		if(multiChildTypeList.size() < 1){
			return 0;
		}else {
			int type = multiChildTypeList.removeFirst();
			setUpdateOption();
			return type;
		}
	}

	public LinkedList<Integer> getEventIdList() {
		return eventIdList;
	}

	public void setEventIdList(LinkedList<Integer> eventIdList) {
		this.eventIdList = eventIdList;
		setUpdateOption();
	}

	public int getEventCount(){
		return eventIdList.size();
	}

	public void addEventId(int eventId){
		eventIdList.addLast(eventId);
		setUpdateOption();
	}

	public int getEventId(){
		if(getEventCount() > 0){
			return eventIdList.getFirst();
		}
		return 0;
	}

	public int removeEventId(){
		if(eventIdList.size() < 1){
			return 0;
		}
		int id = eventIdList.removeFirst();
		setUpdateOption();
		return id;
	}

	public LinkedList<Integer> getBeautyTrystList() {
		return beautyTrystList;
	}

	public void setBeautyTrystList(LinkedList<Integer> beautyTrystList) {
		this.beautyTrystList = beautyTrystList;
		setUpdateOption();
	}

	public void addBeautyTryst(int beautyId){
		this.beautyTrystList.addLast(beautyId);
		setUpdateOption();
	}

	public int removeBeautyTryst(){
		if(beautyTrystList.size() < 1){
			return 0;
		}else {
			int beautyId = beautyTrystList.removeFirst();
			setUpdateOption();
			return beautyId;
		}
	}



	public int getBrothelBeautyId() {
		return brothelBeautyId;
	}

	public void setBrothelBeautyId(int brothelBeautyId) {
		if(this.brothelBeautyId != brothelBeautyId) {
			this.brothelBeautyId = brothelBeautyId;
		}
	}

	public int getCasinoType() {
		return casinoType;
	}

	public void setCasinoType(int casinoType) {
		if(this.casinoType != casinoType) {
			this.casinoType = casinoType;
			setUpdateOption();
		}
	}

}
